package 每日一题OJ;

/**
 * @author shy_black
 * @date 2019/8/19 22:30
 * @Description:
 */
public class _53_最大子序和 {

    public int maxSubArray(int[] nums) {
        int sum = nums[0];
        int res = nums[0];
        for(int i = 1;i < nums.length;i++) {

            sum = Math.max(sum + nums[i],nums[i]);
            res = Math.max(sum,res);
        }
        return res;
    }
}